package iotest.chario;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

public class CopyFiles {

	public static void main(String[] args) {
		fileCopy();
	}
	

	private static void fileCopy() {
		Reader fileReader = null;
		Writer fileWriter = null;
		try {
			fileReader = new FileReader("src/test/Test.java");
			fileWriter =  new FileWriter("Test_copy.java");
			char[] chars = new char[1024];
			int len =-1;
			while ((len = fileReader.read(chars))!=-1) {
				fileWriter.write(chars, 0, len);
			}
			fileWriter.flush();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			try {
				if (fileWriter!=null) {
					fileWriter.close();
				}
				if (fileReader!=null) {
					fileReader.close();
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
